<?php

/**
 * [PHPFOX_HEADER]
 */
defined('PHPFOX') or exit('NO DICE!');

/**
 * 
 * 
 * @copyright		[PHPFOX_COPYRIGHT]
 * @author  		Raymond Benc
 * @package 		Phpfox_Component
 * @version 		$Id: index.class.php 300 2009-03-20 13:01:54Z Raymond_Benc $
 */
class Recordvideo_Component_Controller_Index extends Phpfox_Component {

    /**
     * Class process method wnich is used to execute this component.
     */
    public function process() {
        require(PHPFOX_DIR . 'ex' . DIRECTORY_SEPARATOR . 'opentok' . DIRECTORY_SEPARATOR . 'OpenTokSDK.php');

        $apiObj = new OpenTokSDK(Phpfox::getParam('recordvideo.opentok_api_key'),
                Phpfox::getParam('recordvideo.opentok_secret'));

        // Creating an OpenTok server-enabled session
        $session = $apiObj->createSession();
        $sessionId = $session->getSessionId();
        
        $sAccessToken = $apiObj->generate_token($sessionId, RoleConstants::MODERATOR);

        $this->template()
                ->setTitle('Record Video')
                ->setBreadcrumb('Record Video')
                ->setHeader('cache', array(
            '<script type="text/javascript" src="http://static.opentok.com/v1.1/js/TB.min.js"></script>',
            '<script type="text/javascript">
                var API_KEY = ' . Phpfox::getParam('recordvideo.opentok_api_key') . '; // Replace with your API key. See https://dashboard.tokbox.com/projects
            var TOKEN = "' . $sAccessToken . '";                
            </script>',
            'recordvideo.js' => 'module_recordvideo',
            '<script type="text/javascript">$Behavior.recordvideo = function() {
                init();
}</script>'
        ));
    }

    

    /**
     * Garbage collector. Is executed after this class has completed
     * its job and the template has also been displayed.
     */
    public function clean() {
        
    }

}

?>